<{use class="yii\bootstrap\BootstrapAsset"}>
<{BootstrapAsset::register($this)|void}>
<script src="/static/js/dropload.min.js"></script>
<link rel="stylesheet" href="/static/css/dropload.css">
<style>
    .mdwrap{
        margin: 10px 0px 0px 10px;height: 180px;overflow-y: auto;
    }

    .mdwrap img{
        width: 55px;height: 55px;border-radius: 50%;
    }
    .mdwrap div{
        text-align: center;margin-bottom: 10px;
    }

    .flex_row_2 .row_one:nth-child(2n-1){
        width: calc(100% + 7.5px);
    }
    .flex_row_2 .row_one:nth-child(2n){
        width: calc(100% + 7.5px);
    }
    .row_one:nth-child(2n-1) .addcart {
        right: 15px;
        margin-bottom: 12px;
    }
    .row_one .addcart{
        right: 15px;
        margin-bottom: 12px;
    }
    .imglist{
        margin-bottom: 5px;
        width: 98%;
        margin-left: 1%;
        padding:0;
    }

    .row {
        margin-right: 3px;
        margin-left: 3px;
    }
</style>
<input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
<div class="content margin_top_foot">

    <div class="row">
        <div class="first col-md-12 col-xs-12" style="padding: 0">
            <a href=""><img src="<{$banner}>" alt="" style="width: 100%;height: 200px;margin-bottom: 10px;"></a>
        </div>
    </div>

    <div class="searchbar fixed_top bg_mx_green white"></div>
    <div class="refresh_content">
        <div class="pull_refresh">
            <div class="row goods_list pros">
                <{foreach $recommand as $key => $row}>
                    <div class="imglist col-md-12 col-xs-12">
                        <a href="<{if array_key_exists('url',$row)}><{$row['url']}><{/if}>"><img src="<{$row['thumb']}>" alt="" style="width: 100%;"></a>
                    </div>
                <{/foreach}>
            </div>
        </div>
        <div class="refresh_load">
            <div class="refresh_pull_arrow"></div>
        </div>
    </div>
    <div class="sidebar fixed lineheight_4 white hide"></div>
    <div class="sidecon row padding_h_15 fixed lineheight_4 bg_white hide mx_green text_center"></div>
    <footer class="foot_tab fixed_bottom mx_green font_16"></footer>
</div>


<div class="toast"></div>
<!-- toast模版 -->
<script type="text/template" charset="utf-8" id='toast_template'>
    <i class="iconfont icon-toast{{=it.icon}}"></i>
    <div class="toast_text">{{=it.text}}</div>
</script>


<!-- 产品 -->
<script type="text/template" charset="utf-8" id='pro_template'></script>
<script>

    var pros = <{$jsonrecommand}>,evalpros;

    loadfootbar();

    // 页面初始化
    var mycarts = get_data("cart")||{};
    var len = mycarts.total;
    loadsearchbar(function(){
        if(len){
            $(".total").html(len);
        }else{
            $(".total").hide();
        }
    });
    // 搜索
    var evalToast = doT.template($("#toast_template").text());
    $(".content").on("input",".searchbar_input input",function(){
        var that = this;
        var keywords = $(this).val();
        if(keywords){
            $.post("/shop/site/search-goods",{keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                if(res.status && res.status == 1){
                    toast("attention",res.msg)
                }else{
                    $(".pros").html(evalpros(res))
                }
            },"json")
        }
    })
    function search(obj){
        var keywords = $(obj).next().val();
        if(keywords){
            $.post("/shop/site/search-goods",{keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                if(res.status && res.status == 1){
                    toast("attention",res.msg)
                }else{
                    $(".pros").html(evalpros(res))
                }
            },"json")
        }
    }
    // 下拉加载更多
    //     var pindex = 1;
    //     var pullRefresh = new mobileRefresh({
    //         container: document.querySelector('.refresh_content'),
    //         triggerDistance: 100,
    //         type:"up"
    //     },function(){
    //         $.post("/shop/site/load-more",{pindex:++pindex,_csrf:$('#_csrf').val()},function(res){
    //             $(".pros").append(evalpros(res));
    //             pullRefresh.cancelLoading();
    //         },"json")
    //     })
</script>


